import GChild from "../../../Core/GView/GChild";
import ShaderUtil from "../../../Shaders/Manager/ShaderUtil";
import { VIEW_ID } from "../../Common/UI";
import { Res } from "../../Common/UIResources";
import GameMgr from "../../Logic/GameMgr";

const { ccclass, property, menu, executeInEditMode } = cc._decorator;
@ccclass @menu('View/Home/SkillItem')

export default class SkillItem extends GChild {
    @property(cc.Sprite) icon: cc.Sprite = null;
    private _data: SSkillDataRaw = null;
    public setView(data: SSkillDataRaw, bool: boolean) {
        this._data = data;
        if (!bool) {
            ShaderUtil.gray(this.icon.node);

        } else {

        }
        this.assetImpl.spriteAtlasFrame(this.icon, Res.texture.views.skillIcon, data.icon.toString());
    }

    /**点击技能详情 */
    public skillClick() {
        if (this.node.getComponent(cc.Button).interactable) {
            GameMgr.jumpToMgr.jumpGoTo(VIEW_ID.skillPage, this._data)
        }
    }
}